package com.opteron.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Controller;

import com.chiga.controller.BaseAction;
import com.opteron.model.UserInfo;

@Controller
public class BasesAction extends BaseAction {
	
	private static final long serialVersionUID = 3953792406916361326L;
	
	protected static final String SUCCESS = "success";
	protected static final String INPUT = "input";
	
	private Map<String, String> param;
	private Map<String, List<UserInfo>> param2;
	
	public void setParam(Map<String, String> param) {
		this.param = param;
	}
	
	public Map<String, String> getParam() {
		if (this.param == null) this.param = new HashMap<String, String>();
		return this.param;
	}
	
	public String getParameter(String key) {
		return this.param.get(key);
	}
	
	protected HttpServletRequest getRequest() {
		return ServletActionContext.getRequest();
	}
	
	protected HttpSession getSession() {
		return ServletActionContext.getRequest().getSession();
	}
	
	protected UserInfo getUserInfo() {
		HttpSession session = getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute("User");
		return userInfo;
	}

	public Map<String, List<UserInfo>> getParam2() {
		if (this.param2 == null) this.param2 = new HashMap<String, List<UserInfo>>();
		return param2;
	}

	public void setParam2(Map<String, List<UserInfo>> param2) {
		this.param2 = param2;
	}
	
	public List<UserInfo> getParameter2(String key) {
		return this.param2.get(key);
	}
}
